home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / sharewar / FFE / GRAPH.SWG / 0069_TIFF Class F.pas < prev    next >
Pascal/Delphi Source File  |  1997-05-12  |  17KB  |  429 lines

  1. This is the most recent revision of the TIFF Class F specification from
  2. Joe Campbell at Cygnet.
  3.  
  4. ----------------------------------------------------------------------------
  5.  
  6.  
  7.                    THE SPIRIT OF TIFF CLASS F
  8.  
  9. TIFF Classes reduce the information burden on TIFF readers and writers
  10. that wish to support narrow applications. For example, Appendix G-1 of
  11. TIFF 5.0 states that classes enable TIFF readers "to know when they
  12. can stop adding TIFF features."  In other words, defining a Class
  13. enables applications interested only in reading that Class to give up
  14. if the characteristic tags and values are not present.  Therefore,
  15. TIFF Class F insists on a rather narrow definition of tags. In a
  16. general TIFF file, for example, the writer would be free to create
  17. single-page documents without the NewSubFileType and PageNumber tags.
  18. Not so for a Class F file, where the multi-page tag is required even
  19. for a single page.
  20.  
  21. TIFF Class F is a sub-class of Class B (Bilevel).  That is, all tags
  22. that are required in Class B are also required in Class F. For some
  23. common tags, however, Class F limits the range of acceptable values.
  24. The YResolution tag, for example, is a Class B tag, but its Class F
  25. value is limited to either 98 or 196 dpi. Such tags are listed in
  26. "Required Class F Tags."
  27.  
  28. Other Class B tags have a slightly eccentric meaning when applied to
  29. facsimile images.  These are discussed in the section "Bilevel
  30. Required."
  31.  
  32. There are also tags that may be helpful but are not required. These
  33. are listed in the "Recommended Tags" section.
  34.  
  35. Finally, technical topics are discussed in the sections "Technical
  36. Points" and "Warnings."
  37.  
  38.                    REFERENCES
  39.  
  40. Substantive questions about TIFF Class F can be faxed to:
  41.  
  42.           Cygnet Technologies
  43.           2560 9th, Suite 220
  44.           Berkeley, CA 94710
  45.           Fax: (415) 540-5835
  46.  
  47. TIFF Class F is a parallel but unrelated effort to EIA Project Number
  48. 2188, an industry standards group working to standardize facsimile
  49. hardware. For information about this standard, contact Joe Decuir at
  50. the above address or phone (415) 486-2611.
  51.  
  52. Group 3 facsimile is described in the "Red Book", Volume VII, Fascicle
  53. VII.3, Terminal Equipment and Protocols for Telematic Services, The
  54. International Telegraph and Telephone Consultative Committee (CCITT),
  55. Geneva, 1985.
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.                         CLASS F REQUIRED
  63.  
  64.      Compression = 3.  SHORT.   Group 3, one- dimensional encoding
  65. with "byte-aligned" EOLs.  An EOL is  said to be byte-aligned when
  66. Fill bits have been added as  necessary before EOL codes such that EOL
  67. always ends on a byte  boundary, thus ensuring an EOL-sequence of a 1
  68. byte preceded  by a zero nibble: xxxx0000 00000001.  The data in a
  69. Class F image is not terminated with an RTC.  Please see items 4 and 5
  70. in the "Warnings" section.
  71.  
  72.    For two-dimensional encoding, set bit 1 in Group3Options. Please
  73. see item 2 in the "Warnings" section.
  74.  
  75.      FillOrder = 1, 2.  SHORT.  TIFF Class F readers must be able to
  76. read data in both bit orders, but the vast majority of facsimile
  77. products store data LSB first, exactly as it appears on the telephone
  78. line.
  79.  
  80.         1 = Most Significant Bit first.
  81.  
  82.         2 = Least Significant Bit first.
  83.  
  84.      Group3Options = 4,5.  LONG.  Data may be one- or two-dimensional,
  85. but EOLs must be byte-aligned. Uncompressed data is not allowed.
  86.  
  87.         bit 0 = 0 for 1-Dimensional, 1 for 2-Dimensional
  88.  
  89.         bit 1 = must be 0 (uncompressed data not allowed)
  90.  
  91.         bit 2 = 1 for byte-aligned EOLs
  92.  
  93.      ImageWidth = 1728, 2048, 2482.  SHORT or LONG.  These are the
  94. fixed page widths in pixels defined in CCITT Group 3.
  95.  
  96.      NewSubFileType = 2.  LONG.  The value 2 identifies a single page
  97. of a multi-page image.
  98.  
  99.      PageNumber.  SHORT/SHORT.  This tag specifies the page numbers in
  100. the fax document.  The tag comprises two SHORT values: the first value
  101. is the page number, the second is the total number of pages. Single-
  102. page documents therefore use 00000001 hex.
  103.  
  104.      ResolutionUnit = 2,3.  SHORT.  The units of measure for
  105. resolution:
  106.  
  107.         2 = Inch
  108.  
  109.         3 = Centimeter
  110.  
  111.      XResolution = 204 (inches).  RATIONAL. The horizontal resolution
  112. of the image expressed in pixels per resolution unit.
  113.  
  114.      YResolution = 98, 196 (inches).  RATIONAL. The vertical
  115. resolution of the image expressed in pixels per resolution unit.
  116.  
  117.                    BILEVEL REQUIRED
  118.  
  119. Although these tags are already required in Class B (Bi-Level) files,
  120. an explanation of their usage for facsimile images may be helpful.
  121.  
  122.      BitsPerSample = 1.  SHORT.  Since facsimile is a black-and-white
  123. medium, this must be 1 (the default) for all files.
  124.  
  125.      ImageLength.  SHORT or LONG.  LONG recommended. The total number
  126. of scan lines in the image.
  127.  
  128.      PhotometricInterp = 0,1.  SHORT.  This tag allows notation of an
  129. inverted ("negative") image:
  130.  
  131.         0 = normal
  132.  
  133.         1 = inverted
  134.  
  135.      Software.  ASCII.  The optional name and release number of the
  136. software package that created the image.
  137.  
  138.      RowsPerStrip.  SHORT or LONG.  LONG recommended. The number of
  139. scan lines per strip.  When a page is expressed as one large strip,
  140. this is the same as the ImageLength tag.
  141.  
  142.      SamplesPerPixel = 1.  SHORT.  The value of 1 denotes a bi-level,
  143. grayscale, or palatte color image.
  144.  
  145.      StripByteCounts.  SHORT or LONG.  SHORT recommended. For each
  146. strip, the number of bytes in that strip. If a page is expressed as
  147. one large strip, this is the total number of bytes in the page after
  148. compression.
  149.  
  150.      StripOffsets.  SHORT or LONG.  For each strip, the offset of that
  151. strip.  The offset is measured from the beginning of the file. If a
  152. page is expressed as one large strip, there is one such entry per
  153. page.
  154.  
  155.                    NEW TAGS
  156.  
  157. There are only three new tags for Class F.  All three tags describe
  158. page quality.  The information contained in these tags is usually
  159. obtained from the receiving facsimile hardware, but since not all
  160. devices are capable of reporting this information, the tags are
  161. optional.
  162.  
  163. Some applications need to understand exactly the error content of the
  164. data.  For example, a CAD program might wish to verify that a file has
  165. a low error level before importing it into a high- accuracy document.
  166. Because Group 3 facsimile devices do not necessarily perform error
  167. correction on the image data, the quality of a received page must be
  168. inferred from the pixel count of decoded scan lines. A "good" scan
  169. line is defined as a line that, when decoded, contains the correct
  170. number of pixels. Conversely, a "bad" scan line is defined as a line
  171. that, when decoded, comprises an incorrect number of pixels.
  172.      BadFaxLines
  173.          Tag  = 326  (146 hex)
  174.          Type = SHORT or LONG
  175.  
  176. This tag reports the number of scan lines with an incorrect number of
  177. pixels encountered by the facsimile during reception (but not
  178. necessarily in the file).
  179.  
  180.                Note: PercentBad = (BadFaxLines/ImageLength) * 100
  181.  
  182.  
  183.      CleanFaxData
  184.          Tag = 327 (147 hex)
  185.          Type = SHORT
  186.  
  187.             N = 0
  188.  
  189.                          0 = Data  contains  no lines  with  incorrect
  190.                              pixel counts or regenerated lines  (i.e.,
  191.                              computer generated)
  192.  
  193.  
  194.                          1 = Lines with an incorrect pixel count  were
  195.                              regenerated by receiving device
  196.  
  197.  
  198.                          2 = Lines  with  an  incorrect  pixel   count
  199.                              existed,  but  were  not  regenerated  by
  200.                              receiving device
  201.  
  202. Many facsimile devices do not actually output bad lines. Instead,  the
  203. previous good line is repeated in place of a bad  line. Although  this
  204. substitution,  known  as  line   regeneration,  results  in  a  visual
  205. improvement  to the image,  the data is nevertheless  corrupted.   The
  206. CleanFaxData  tag  describes the error content of the data.  That  is,
  207. when the  BadFaxLines and ImageLength tags indicate that the facsimile
  208. device  encountered lines with an incorrect number of  pixels   during
  209. reception,  the  CleanFaxData tag indicates whether these   lines  are
  210. actually  in the data or if the receiving facsimile   device  replaced
  211. them with regenerated lines.
  212.  
  213.      ConsecutiveBadFaxLines
  214.          Tag  = 328 (148 hex)
  215.          Type =  LONG or SHORT
  216.  
  217. This tag reports the maximum number of consecutive lines containing an
  218. incorrect number of pixels encountered by the facsimile device  during
  219. reception (but not necessarily in the file).
  220.  
  221. The  BadFaxLines  and ImageLength data indicate only the  quantity  of
  222. such  lines.  The ConsecutiveBadFaxLines tag is an indicator of  their
  223. distribution  and  may  therefore be a  better  general  indicator  of
  224. perceived image quality.
  225.  
  226.  
  227.                         RECOMMENDED TAGS
  228.  
  229.      BadFaxLines.  LONG.  The number of "bad" scan lines
  230. encountered by the facsimile during reception.
  231.  
  232.      CleanFaxData = 0, 1, 2.  BYTE.  This tag indicates whether
  233. lines with incorrect pixel count are actually in the data or if
  234. the receiving facsimile device replaced them with regenerated
  235. lines.
  236.  
  237.                          0 = Data contains no lines with incorrect
  238.                              pixel counts or regenerated lines (i.e.,
  239.                              computer generated)
  240.  
  241.                          1 = Lines with an incorrect pixel count were
  242.                              regenerated by receiving device
  243.  
  244.                          2 = Lines with an incorrect pixel count
  245.                              existed, but were not regenerated by
  246.                              receiving device
  247.  
  248.      ConsecutiveBadFaxLines.  LONG or SHORT. The maximum number of
  249. consecutive scan lines with incorrect pixel count encountered by the
  250. facsimile device reception.
  251.  
  252.      DateTime.  ASCII.  Date and time in the format YYYY:MM:DD
  253. HH:MM:SS, in 24-hour format. String length including NUL byte is 20
  254. bytes. Space between DD and HH.
  255.  
  256.      DocumentName.  ASCII.  This is the name of the document from
  257. which the document was scanned.
  258.  
  259.      ImageDescription.  ASCII.  This is an ASCII string describing the
  260. contents of the image.
  261.  
  262.      Orientation.  SHORT.  This tag might be useful for displayers
  263. that always want to show the same orientation, regardless of the
  264. image.  The default value of 1 is "0th row is visual top of image, and
  265. 0th column is the visual left."  An 180-degree rotation is 3.  See
  266. TIFF 5.0 for an explanation of other values.
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.                    TECHNICAL POINTS
  283.  
  284. 1.  Strips  Those new to TIFF may not be familiar with the concept of
  285. "strips" embodied in the three tags RowsPerStrip, StripByteCount,
  286. StripOffsets.
  287.  
  288.      In general, third-party applications that read and write TIFF
  289. files expect the image to be divided into "strips," also known as
  290. "bands."  Each strip contains a few lines of the image. By using
  291. strips, a TIFF reader need not load the entire image into memory, thus
  292. enabling it to fetch and decompress small random portions of the image
  293. as necessary.
  294.  
  295.      The dimensions of a strip are described by the RowsPerStrip and
  296. StripByteCount tags.  The location in the TIFF file of each strip is
  297. contained in the StripOffsets tag.
  298.  
  299.      The TIFF documentation suggests using strips of an arbitrary size
  300. of about 8K.  Although various application programs assert that they
  301. "prefer" banded images, research failed to uncover a single existing
  302. application that could not read a single-strip page where they could
  303. read the same file in a multi- strip format. Indeed, applications seem
  304. to be more sensitive to the total size of the decoded image and are
  305. not particularly fussy about banding.  This result is not surprising,
  306. considering that most desktop publishing programs are prepared to deal
  307. with massively larger images than those one finds in facsimile.  In
  308. short, each page may be represented as a single strip of any length.
  309.  
  310.      In fact, there may be a compelling reason to employ a strip size
  311. equal to the length of one A4 page (297 mm).  When a document is
  312. imaged, it may be of any length.  Not all fax machines, however, can
  313. accept unlimited length documents. Worse, the remote machine's page-
  314. length capability is not known until the fax connection has been
  315. established.  The solution is for the transmitting fax device to image
  316. long documents into A4-size strips, then seam them together at
  317. transmission, after the capabilities of the remote fax machine is
  318. known.
  319.  
  320. 2.  Bit Order  Although the TIFF 5.0 documentation lists the FillOrder
  321. tag in the category "No Longer Recommended," Class F resurrects it.
  322. Facsimile data appears on the phone line in bit-reversed order
  323. relative to its description in CCITT Recommendation T.4.  Therefore, a
  324. wide majority of facsimile applications choose this natural order for
  325. storage. Nevertheless, TIFF Class F readers must be able to read data
  326. in both bit orders.
  327.  
  328. 3.  Multi-Page  Many existing applications already read Class F-like
  329. files, but do not support the multi- page tag.  Since a multi-page
  330. format greatly simplifies file management in fax application software,
  331. Class F specifies multi- page documents (NewSubfileType = 2).
  332.  
  333. 4.  Two-dimensional Encoding  PC Fax applications that wish to support
  334. two-dimensional encoding may do so by setting Bit 0 in the
  335. Group3Options tag.  Please see item 2 in the "Warnings" section.
  336.  
  337.  
  338.  
  339. 5.  Example Use of Page-quality Tags  Here are examples for writing
  340. the CleanFaxData,  BadFaxLines, and ConsecutiveBadFaxLines tags:
  341.  
  342.      1.  Facsimile hardware does not provide page quality information:
  343. write no tags.
  344.  
  345.      2.  Facsimile hardware provides page quality information, but
  346. reports no bad lines.  Write only BadFaxLines = 0.
  347.  
  348.      3.  Facsimile hardware provides page quality information, and
  349. reports bad lines.  Write both BadFaxLines and ConsecutiveBadFaxLines.
  350. Also write CleanFaxData = 1 or 2 if the hardware's regeneration
  351. capability is known.
  352.  
  353.      4.  Computer generated file:  write CleanFaxData = 0.
  354.  
  355.  
  356.               WHAT CONSTITUTES TIFF CLASS F SUPPORT
  357.  
  358. Fax applications that do not wish to embrace TIFF Class F as a native
  359. format may elect to support it as import/export medium.
  360.  
  361.      Export  The simplest form of support is a Class F writer that
  362. produces individual single-page Class F  files with the proper
  363. NewSubFile tag and the PageNumber (page  one-of-one) tag.
  364.  
  365.      Import  A Class F reader must be able to handle a Class F file
  366. containing multiple pages.
  367.  
  368.                             WARNINGS
  369.  
  370. 1.  Class F requires the ability to read and write at least one-
  371. dimensional T.4 Huffman ("compressed") data. Due to the disruptive
  372. effect to application software of line-length  errors and because such
  373. errors are likely in everyday facsimile transmissions, uncompressed
  374. data is not allowed.  In other words, "Uncompressed" bit in
  375. Group3Options must be 0.
  376.  
  377. 2.  Since two-dimensional encoding is not required for Group 3
  378. compatibility, Class F readers may decline to read such files.
  379. Therefore, for maximum portability write only one- dimensional files.
  380. Although the same argument technically holds for "fine" (196 dpi)
  381. vertical resolution, only a tiny fraction of facsimile products
  382. support only 98 dpi.  Therefore, high-resolution files are quite
  383. portable in the real world.
  384.  
  385. 3.  In the spirit of TIFF, all EOLs in data must be byte- aligned. An
  386. EOL is said to be byte-aligned when Fill bits have been added as
  387. necessary before EOL codes such that EOL always ends on a byte
  388. boundary, thus ensuring an  EOL-sequence of a one byte preceded by a
  389. zero nibble: xxxx0000 00000001.
  390.  
  391.      Recall that Huffman encoding encodes bits, not bytes. This means
  392. that the end-of-line token may end in the middle of a byte. In byte
  393. alignment, extra zero bits (Fill) are added so that the first bit of
  394. data following an EOL begins on a byte boundary. In effect, byte
  395. alignment relieves application software of the burden of bit-shifting
  396. every byte while parsing scan lines for line-oriented image
  397. manipulation (such as writing a TIFF file).
  398.  
  399. 4.  As illustrated in FIGURE 1/T.4 in Recommendation T.4 (the Red
  400. Book, page 20), facsimile documents begin with an EOL (which in Class
  401. F is byte-aligned). The last line of the image is not terminated by an
  402. EOL.
  403.  
  404. 5.  Aside from EOL's, TIFF Class F files contain only image data. This
  405. means that the Return To Control sequence (RTC) is specifically
  406. prohibited. Exclusion of RTC's not only makes possible the simple
  407. concatenation of images, it eliminates the mischief--failed
  408. communications and unreadable images--that their mistreatment
  409. inevitably produces.  (This view is reflected in the work of the EIA
  410. PN2188 committee, where the modem device attaches the  RTC outbound
  411. and removes it inbound.)
  412.  
  413.                         REVISION HISTORY
  414.  
  415. 11/17/89: Initial Publication
  416.  
  417. 4/29/90 : First revision
  418.  
  419. PageNumber tag was incorrectly illustrated as page one. The correct
  420. number for the first page is zero.
  421.  
  422.  
  423.  
  424. --
  425. Stuart.Lynne@wimsey.bc.ca ubc-cs!van-bc!sl 604-937-7532(voice) 604-939-4768(fax)
  426.  
  427.  
  428.